package com.wwl.deliveryappointmentbackend.control.sys;

import com.wwl.deliveryappointmentbackend.model.User;
import com.wwl.deliveryappointmentbackend.service.UserService;
import com.wwl.deliveryappointmentbackend.utils.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/sys/users")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/findall")
    public Response<List<User>> findall() {
        return Response.yes(userService.findAll());
    }
    @GetMapping("/{username}")
    public Response<User> findByUserName(@PathVariable String username) {
        return Response.yes(userService.findByUserName(username));
    }
    @PostMapping("/login")
    public Response<User> findByUserName(@RequestParam String username,
                                         @RequestParam String pwd) {
        return Response.yes(userService.findByUserName(username));
    }


}
